package com.ibeeking.gmc.global.g.rest.controller.v1;

import com.ibeeking.gmc.global.g.rest.service.ICampaignSceneService;
import com.ibeeking.gmc.global.service.common.param.CampaignSceneParam;
import com.ibeeking.gmc.global.service.common.query.CampaignScenePageQuery;
import com.ibeeking.gmc.global.service.common.vo.CampaignSceneTypeVO;
import com.ibeeking.gmc.global.service.common.vo.CampaignSceneVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @ClassName CampaignSceneController控制器
 * @Description 活动场景
 * @Author ibeeking
 * @Date 2020-12-01 18:15
 **/
@RestController
@RequestMapping("/b/campaignScene/v1")
public class CampaignSceneController {

    @Resource
    private ICampaignSceneService campaignSceneServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "活动场景分类列表")
    @PostMapping(value = "/sceneTypes")
    public List<CampaignSceneTypeVO> sceneTypes() {
        return campaignSceneServiceImpl.sceneTypes();
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "活动场景分页查询")
    @PostMapping(value = "/pageList")
    public Page<CampaignSceneVO> pageList(@RequestBody CampaignScenePageQuery query) {
        return campaignSceneServiceImpl.pageList(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "活动场景新增")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) CampaignSceneParam param) {
        return campaignSceneServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "活动场景修改")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) CampaignSceneParam param) {
        return campaignSceneServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "活动场景查看")
    @GetMapping(value = "/view/{id}")
    public CampaignSceneVO view(@PathVariable(value = "id") @NotNull(message = "活动场景id必填") Long id) {
        return campaignSceneServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "活动场景删除")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable(value = "id") @NotNull(message = "活动场景id必填") Long id) {
        return campaignSceneServiceImpl.del(id);
    }
}
